package com.bamboo.ucenterservice.controller;


import com.bamboo.commonutils.ResponseEntity;
import com.bamboo.ucenterservice.entity.RegisterVo;
import com.bamboo.ucenterservice.entity.UcenterMember;
import com.bamboo.ucenterservice.service.UcenterMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 会员表 前端控制器
 * </p>
 *
 * @author jack.wu
 * @since 2020-07-14
 */
@Api(description = "用户管理")
@RestController
@RequestMapping("/ucenterservice/member")
@CrossOrigin
public class UcenterMemberController {

    @Resource
    private UcenterMemberService memberService;

    @ApiOperation(value = "用户注册")
    @PostMapping("/register")
    public ResponseEntity registerMember(@RequestBody RegisterVo registerVo) {
        // todo 需要做校验  校验注解
        memberService.registerMember(registerVo);
        return ResponseEntity.ok();
    }

    @ApiOperation(value = "根据用户id查询用户信息")
    @GetMapping("/{id}")
    public UcenterMember getMemberInfo(@PathVariable String id) {
        return memberService.getById(id);

    }

    @ApiOperation(value = "查询当天注册人数")
    @GetMapping("registerCount/{day}")
    public int getRegisterCount(@PathVariable String day){
       return memberService.getRegisterCount(day);
    }

}

